package demo6;

class MyArray {
    public <E extends Comparable<E>> E findMax(E[] Array) {
        E max = Array[0];
        for (int i = 0; i < Array.length; i++) {
            if (max.compareTo(Array[i]) < 0) {
                max = Array[i];
            }
        }
        return max;
    }
}
public class Test {
    public static void main(String[] args) {
        MyArray myArray = new MyArray();
        Double[] doubles = new Double[]{1.0,2.0,2.0,3.0,4.0,5.0,6.0};
        Double max =  myArray.<Double>findMax(doubles);  // <Double> 可以省略
        System.out.println(max);
    }
}
